package com.example.asus.a1127;

import android.animation.ValueAnimator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class ValueAnimatorTestActivity extends AppCompatActivity {
    Button button;
    ImageView kkk;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_value_animator_test);
      /*  ValueAnimator valueAnimator=ValueAnimator.ofInt(0,3);
        valueAnimator.setDuration(3000);
        valueAnimator.setRepeatCount(0);

        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int currentValue=(int)valueAnimator.getAnimatedValue();
                System.out.println("----"+currentValue);
            }
        });
        valueAnimator.start();*/
       button=(Button)findViewById(R.id.button);
       kkk= (ImageView) findViewById(R.id.kkk);
       int width=button.getLayoutParams().width;
        //final View view=findViewById(R.id.kkk);
       System.out.println("----"+width);
        ValueAnimator valueAnimator = ValueAnimator.ofInt(width,1000);
        valueAnimator.setDuration(3000);
        valueAnimator.setRepeatCount(0);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(){

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int val = (int) valueAnimator.getAnimatedValue();
                System.out.println("----val:"+val);
                button.getLayoutParams().width = val;
                button.requestLayout();
            }
        });
        valueAnimator.start();



    }
}
